<%@ include file="/common/taglibs.jsp"%>
<%@ page language="java" import="java.util.*" pageEncoding="utf8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"
	dir="ltr">
	<head>

		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" href="<c:url value="/css/shopadmin.css"/>"
			type="text/css" />
		<link rel="stylesheet"
			href="<c:url value='/scripts/themes/base/jquery.ui.all.css'/>"
			type="text/css" />
	</head>
	<body style="">



		<div class="head_content" id="headBar">
			<div id=" " class="finder-action">
				<div class="finder-action-inner clearfix">
					<a class="btn btn-blank" href=""> <span><span><i
								class="finder-icon"><img
										style="width: 24px; height: 24px; background-position: 0pt -316px;"
										class="imgbundle icon"
										src="<c:url value="/images/transparent.gif"/>">
							</i>添加会员</span> </span> </a>
					<button class="btn" type="button">
						<span><span><i class="finder-icon"><img
										style="width: 22px; height: 24px; background-position: 0pt -524px;"
										class="imgbundle icon"
										src="<c:url value="/images/transparent.gif"/>">
							</i>群发<img class="drop-handle"
									src="<c:url value="/images/transparent.gif"/>">
						</span> </span>
					</button>
					<button class="btn btn-large" type="button" id="member_update_btn">
						<span><span><i class="finder-icon"><img
										style="width: 22px; height: 24px; background-position: 0pt -548px;"
										class="imgbundle icon"
										src="<c:url value="/images/transparent.gif"/>">
							</i>批量编辑</span> </span>
					</button>
					<button class="btn" onclick='location.reload()' type="button">
						<span><span><i class="finder-icon"><img
										style="width: 22px; height: 24px; background-position: 0pt -644px;"
										class="imgbundle icon"
										src="<c:url value="/images/transparent.gif"/>">
							</i>刷新</span> </span>
					</button>
					<button class="btn" type="button" id="member_search_btn">
						<span><span><i class="finder-icon"><img
										style="width: 26px; height: 24px; background-position: 0pt -460px;"
										class="imgbundle icon"
										src="<c:url value="/images/transparent.gif"/>">
							</i>筛选</span> </span>
					</button>
				</div>
			</div>

			<div class="finder-header">

				<table width="100%" cellspacing="0" cellpadding="0">
					<!----cols---->
					<col class="span-select" style="width: 24px;" />
					<col style="width: 48px;" />
					<col idx="1" style="width: 75px;" />
					<col idx="2" style="width: 75px;" />
					<col idx="3" style="width: 75px;" />
					<col idx="4" style="width: 30px;" />
					<col idx="5" style="width: 110px;" />
					<col idx="6" style="width: 75px;" />
					<col idx="7" style="width: 110px;" />
					<col idx="8" style="width: 75px;" />
					<col idx="9" style="width: 50px;" />
					<col idx="10" style="width: 110px;" />
					<col />
					<!----cols---->
					<thead>
						<tr>
							<td>
								<input type="checkbox" id="member_ids" class="sellist">
							</td>
							<td style="width: 48px;">
								&nbsp;查看
							</td>
							<td>
								<div key="uname" class="cell orderable">
									<table width="100%" cellspacing="0" cellpadding="0">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">用户名</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div key="member_lv_id" class="cell orderable">
									<table width="100%" cellspacing="0" cellpadding="0">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">会员等级</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div key="name" class="cell orderable">
									<table width="100%" cellspacing="0" cellpadding="0">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">姓名</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div key="sex" class="cell orderable">
									<table width="100%" cellspacing="0" cellpadding="0">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">性别</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div key="email" class="cell orderable">
									<table width="100%" cellspacing="0" cellpadding="0">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">EMAIL</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div key="regtime" class="cell orderable">
									<table width="100%" cellspacing="0" cellpadding="0">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">注册时间</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div key="point" class="cell orderable">
									<table width="100%" cellspacing="0" cellpadding="0">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">积分</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div key="mobile" class="cell orderable">
									<table width="100%" cellspacing="0" cellpadding="0">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">手机</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div key="remark" class="cell orderable">
									<table width="100%" cellspacing="0" cellpadding="0">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">备注</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								<div key="area" class="cell orderable">
									<table width="100%" cellspacing="0" cellpadding="0">
										<tbody>
											<tr>
												<td>
													<span class="finder-col-label">地区</span>
												</td>
											</tr>
										</tbody>
									</table>
								</div>
							</td>
							<td>
								&nbsp;
							</td>
						</tr>
					</thead>
				</table>
			</div>
		</div>
		<div class="main_content" id="main">
			<div id=" " class="finder-list finder-list-normal">
				<table width="100%" cellspacing="0" cellpadding="0"
					id="member_list_table">
					<!----cols---->
					<col class="span-select" style="width: 24px;" />
					<col style="width: 48px;" />
					<col idx="1" style="width: 75px;" />
					<col idx="2" style="width: 75px;" />
					<col idx="3" style="width: 75px;" />
					<col idx="4" style="width: 30px;" />
					<col idx="5" style="width: 110px;" />
					<col idx="6" style="width: 75px;" />
					<col idx="7" style="width: 110px;" />
					<col idx="8" style="width: 75px;" />
					<col idx="9" style="width: 50px;" />
					<col idx="10" style="width: 110px;" />
					<col />
					<!----cols---->
					<tbody>
						<c:forEach var="member" items="${memberss}"
							varStatus="memberIndex">

							<tr item-id="1" class="row">
								<td>
									<input type="checkbox" onclick=changeColor(this);
										value="${member.memberId }"
										name="memberss[${memberIndex.index }].memberId" class="sel" />
								</td>
								<td class="finder-list-command">

									<a target="_blank" href="mb_member_edit.html?memberId=${member.memberId}"><img
											style="width: 16px; height: 16px; background-position: 0pt -1811px;"
											class="imgbundle"
											src="<c:url value="/images/transparent.gif"/>">
									</a>
								</td>
								<td key="uname">
									<div class="cell">
										${member.uname}
									</div>
								</td>
								<td class="editable" key="member_lv_id">
									<div class="cell">
										${member.memberLvId}
									</div>
								</td>
								<td class="editable" key="name">
									<div class="cell">
										${member.name}
									</div>
								</td>
								<td class="editable" key="sex">
									<div class="cell">
										${member.sex}
									</div>
								</td>
								<td class="editable" key="email">
									<div class="cell">
										${member.email}
									</div>
								</td>
								<td key="regtime">
									<div class="cell">
										${member.regTimeDate}
									</div>
								</td>
								<td key="point">
									<div class="cell">
										${member.point}
									</div>
								</td>
								<td class="editable" key="mobile">
									<div class="cell">
										${member.mobile}
									</div>
								</td>
								<td key="remark">
									<div class="cell">
										${member.remark }
									</div>
								</td>
								<td key="area">
									<div class="cell">
										${member.area }
									</div>
								</td>
								<td>
									&nbsp;
								</td>
							</tr>
						</c:forEach>
					</tbody>
				</table>

			</div>

		</div>
		<div class="foot_content" id="footBar">
			<div id=" " class="finder-footer">
				<div class="finder-page clearfix">
					<div class="span-3">

					</div>
					<div class="span-auto">
						${pagerString }
					</div>
					<div class="span-auto textright">
						共
						<i>${totalRecord}</i>条
					</div>
				</div>
			</div>
		</div>
		<div id="member_update_dialog" title="会员批量更新" style="display: none;">
			<form id="member_update_form" method="post" onsubmit="return checkLevel();"
				action="<c:url value="mb_member_update.html" />">
				<div container="true" class="dialog-content-body"	 >
					<div class="division">
						<div class="notice">

							小提示：批量修改保存后将影响所有已选中的项目，并且不可恢复，请提交前认真核实!
						</div>
						<table cellspacing="0" cellpadding="0" border="0">
							<tbody>
								<tr>
									<th style="width: 50px;">
										请选择
									</th>
									<th>
										&nbsp;
									</th>
									<td>
										&nbsp;
									</td>
								</tr>
								<tr>
									<th style="width: 50px;">

									</th>
									<th>
										<label for="bated_ipt_member_lv_id">
											原会员等级
										</label>
									</th>
									<td>
										<div class="object-select clearfix">
											<select name="memberParameter.oldMemberLevelId"
												id="oldMemberLevelId">
												<c:forEach var="level" items="${memberLevels}">
													<option value="${level.mlId }">
														${level.name}
													</option>
												</c:forEach>
											</select>
										</div>
									</td>
								</tr>
								<tr>
									<th style="width: 50px;">

									</th>
									<th>
										<label for="bated_ipt_point">
											便更后会员等级
										</label>
									</th>
									<td>
										<select name="memberParameter.memberLevelId"
											id="newMemberLevelId">
											<c:forEach var="level" items="${memberLevels}">
												<option value="${level.mlId }">
													${level.name}
												</option>
											</c:forEach>
										</select>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
				<div class="dialog-content-foot" style="">
					<center>
						<button class="btn" id="batch_edit_btn" type="submit">
							<span><span>保存</span> </span>
						</button>
					</center>
				</div>
			</form>
		</div>		
		<div id="member_search_dialog" title="会员搜索" style="display: none;">
			<form id="member_search_form" method="post"  action="<c:url value="mb_member_list.html" />">
				<div container="true" class="dialog-content-body">
					
					<div id="">
						<div class="gridlist">
							<div name="member_lv_id" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										会员等级
									</div>
									<div tp="allege" class="span-3">
										&nbsp;
									</div>
									<div tp="input" class="span-7">
										<div class="object-select clearfix" >
											<select name="memberParameter.memberLevelId" id="search_memberLevelId">
												<option value="">无</option>
											<c:forEach var="level" items="${memberLevels}">
												<option value="${level.mlId }">
													${level.name}
												</option>
											</c:forEach>
										</select>
										</div>
									</div>
									<div class="span-1"></div>
								</div>
							</div>
							<div name="uname" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										用户名
									</div>
									<div tp="allege" class="span-3">
										&nbsp;
									</div>
									<div tp="input" class="span-7">
										<input type="text" value="${memberParameter.uname}"   name="memberParameter.uname" class="x-input " />
									</div>
									<div class="span-1"></div>
								</div>
							</div>
							<div name="name" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										姓名
									</div>
									<div tp="allege" class="span-3">
										&nbsp;
									</div>
									<div tp="input" class="span-7">
										<input type="text" value="${memberParameter.name}"  name="memberParameter.name" class="x-input "  />
									</div>
									<div class="span-1"></div>
								</div>
							</div>
							<div name="area" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										地区
									</div>
									<div tp="allege" class="span-3">
										&nbsp;
									</div>
									<div tp="input" class="span-7">
										<span  class="span _x_ipt"  >
												
										 		<input type="hidden" id="member_province_hidden" value="${memberParameter.province}" name="memberParameter.province" />
										 		<input type="hidden" id="member_city_hidden"  value="${memberParameter.city}" name="memberParameter.city" />
												<select id="member_province"  onchange="findSubRegions(this,'member_city','member_province_hidden');$('#member_city_hidden').val('');"  >
													<option value="">														
														<c:if test="${empty memberParameter.province}">请选择...</c:if>
														<c:if test="${not empty memberParameter.province}">${memberParameter.province}</c:if>
													</option>
													<c:forEach var="region" items="${systemRegionses}">
														<option value="${region.regionId}">
															${region.localName}
														</option>
													</c:forEach>												
												</select>
												
												<select id="member_city"  onchange="findSubRegions(this,'member_area','member_city_hidden')"  >
													<option value="">
														<c:if test="${empty memberParameter.city}">请选择...</c:if>
														<c:if test="${not empty memberParameter.city}">${memberParameter.city}</c:if>
													</option> 											
												</select>
												<select id="member_area" name="memberParameter.regionId"  >
													<option value="">
														请选择...
													</option> 											
												</select>
										</span>
									</div>
									<div class="span-1"></div>
								</div>
							</div>
							<div name="mobile" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										手机
									</div>
									<div tp="allege" class="span-3">
										&nbsp;
									</div>
									<div tp="input" class="span-7">
										<input type="text" value="${memberParameter.mobile}"  name="memberParameter.mobile" class="x-input "/>
									</div>
									<div class="span-1"></div>
								</div>
							</div>
							<div name="tel" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										固定电话
									</div>
									<div tp="allege" class="span-3">
										&nbsp;
									</div>
									<div tp="input" class="span-7">
										<input type="text"  name="memberParameter.tel"  value="${memberParameter.tel}" class="x-input " />
									</div>
									<div class="span-1"></div>
								</div>
							</div>
							<div name="email" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										EMAIL
									</div>
									<div tp="allege" class="span-3">
										&nbsp;
									</div>
									<div tp="input" class="span-7">
										<input type="text"  name="memberParameter.email" value="${memberParameter.email}" class="x-input " />
									</div>
									<div class="span-1"></div>
								</div>
							</div>
							<div style="display: none;" name="zip" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										邮编
									</div>
									<div tp="allege" class="span-3">										
										&nbsp;
									</div>
									<div tp="input" class="span-7">
										<input type="text" name="aa"  value=" " class="x-input " />
									</div>
									<div class="span-1">
										
									</div>
								</div>
							</div>
							<div style="display: none;" name="addr" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										地址
									</div>
									<div tp="allege" class="span-3">
										 
										&nbsp;
									</div>
									<div tp="input" class="span-7">
										<input type="text" name="memberParameter.addr" value="${memberParameter.addr}" class="x-input " />
									</div>
									<div class="span-1">
										 
									</div>
								</div>
							</div>
							
							<div style="display: none;" name="sex" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										性别
									</div>
									<div tp="allege" class="span-3">
										是&nbsp;
									</div>
									<div tp="input" class="span-7">
										<select   name="memberParameter.sex" id="search_sex"
											class="x-input-select  inputstyle">
											<option value="">
												请选择
											</option>
											<option value="false">
												女
											</option>
											<option value="true"  >
												男
											</option>
										</select>
									</div>
									<div class="span-1">
										 
									</div>
								</div>
							</div>
							
							<div style="display: none;" name="point" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										积分
									</div>
									<div tp="allege" class="span-3">
										<select   name="memberParameter.pointSelector"  id="search_pointSelector"
											class="x-input-select  inputstyle">
											<option value="than">
												大于
											</option>
											<option value="lthan">
												小于
											</option>
											<option value="equal">
												等于
											</option>
											<option value="sthan">
												小于等于
											</option>
											<option value="bthan">
												大于等于
											</option>
										</select>
										&nbsp;
									</div>
									<div tp="input" class="span-7">
										<input type="text"   name="memberParameter.point" class="x-input " value="${memberParameter.point}" />
									</div>
									<div class="span-1">
										<span class="opt"><img
												style="width: 16px; height: 16px; background-position: 0pt -214px;"
												class="imgbundle _close" title="删除"
												src="<c:url value="/images/transparent.gif"/>">
										</span>
									</div>
								</div>
							</div>
							<div name="regtime" class="row">
								<div class="row-line">
									<div tp="label" class="span-3">
										注册时间
									</div>
									<div tp="allege" class="span-3">
										 &nbsp;
									</div>
									<div tp="input" class="span-7">
										 
											<input type="text" size="10"  id="search_regtimeBegin" value="${memberParameter.regTimeBegin }"
												name="memberParameter.regTimeBegin"  class="cal " />
												- 
											<input type="text" size="10"   id="search_regtimeEnd" value="${memberParameter.regTimeEnd }"
														name="memberParameter.regTimeEnd"   class="cal "/>
									</div>
									<div class="span-1"></div>
								</div>
							</div>
							
						</div>
					</div>
				</div>
				<div class="dialog-content-foot" style="">
					<center>
						<button class="btn" id="batch_edit_btn" type="submit">
							<span><span>搜索</span> </span>
						</button>
					</center>
				</div>
			</form>
		</div>

		<script type="text/javascript"
			src="<c:url value='/scripts/jquery-1.4.2.js'/>"></script>
		<%@ include file="/jsp/admin/common/messages.jsp"%>
		<script type="text/javascript"
			src="<c:url value='/scripts/ui/jquery.ui.core.js'/>"></script>
		<script type="text/javascript"
			src="<c:url value='/scripts/ui/jquery.ui.widget.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/jquery.ui.datepicker.js'/>"></script>
		<script type="text/javascript" src="<c:url value='/scripts/ui/i18n/jquery.ui.datepicker-zh-CN.js'/>"></script>
		
		
		<script type="text/javascript"
			src="<c:url value='/scripts/ui/jquery.ui.mouse.js'/>"></script>
		<script type="text/javascript"
			src="<c:url value='/scripts/ui/jquery.ui.button.js'/>"></script>
		<script type="text/javascript"
			src="<c:url value='/scripts/ui/jquery.ui.draggable.js'/>"></script>
		<script type="text/javascript"
			src="<c:url value='/scripts/ui/jquery.ui.position.js'/>"></script>
		<script type="text/javascript"
			src="<c:url value='/scripts/ui/jquery.ui.resizable.js'/>"></script>
		<script type="text/javascript"
			src="<c:url value='/scripts/ui/jquery.ui.dialog.js'/>"></script>
		<script type="text/javascript"
			src="<c:url value='/scripts/ui/jquery.effects.core.js'/> "></script>
		 
		
		<script type="text/javascript">
	$(function() {		
		
		$("#member_update_dialog").dialog( {
			autoOpen : false,
			height : 350,
			width : 550,
			modal : true,
			buttons: {
				
			},
			close : function() {

			}
		});
		
		

		$('#member_update_btn').click(function() {
			$('#member_update_dialog').dialog('open');
		});
		
		
		
		
		$("#member_search_dialog").dialog( {
			autoOpen : false,
			height : 420,
			width : 750,
			modal : true,
			buttons: {
				
			},
			close : function() {

			}
		});
		
		$('#member_search_btn').click(function() {
			$('#member_search_dialog').dialog('open');
		});

	});
 

	$("#search_regtimeBegin").datepicker( $.datepicker.regional['zh-CN']);
	$("#search_regtimeEnd").datepicker( $.datepicker.regional['zh-CN']);

	<c:if test="${not empty memberParameter}" >		   
		   $('#search_memberLevelId').attr('value', '${memberParameter.memberLevelId}');
			$('#search_sex').attr('value','${memberParameter.sex}');
			$('#search_pointSelector').attr('value','${memberParameter.pointSelector }');
				
		</c:if>



	function checkLevel() {
		
		var oldLevelId = $('#oldMemberLevelId').attr('value');
		var newLevelId = $('#newMemberLevelId').attr('value');
		var submit = true;
		if (oldLevelId == newLevelId) {
			alert('变更前后的会员等级不能一致，请重新选择') ;
			submit = false;  			
		}
		
		return submit;
		
	}

	var selected = 'selected';
	$("#member_ids").click(function() {
		if (this.checked) {
			$('input[type=checkbox]').attr("checked", true);

			$('#member_list_table >tbody > tr').addClass(selected);
		} else {
			$('input[type=checkbox]').attr("checked", false);
			$('#member_list_table >tbody > tr').removeClass(selected);
		}
	});

	function changeColor(obj) {
		if ($(obj).attr("checked")) {
			$(obj).parent().parent().addClass(selected);
		} else {
			$(obj).parent().parent().removeClass(selected);
		}
	}




	function findSubRegions(obj,subId,hiidenId) {
		var url = "<c:url value="/sys_region_list.html" />";  
		var regionId = $(obj).attr('value'); 
		if(regionId==''){
			return;
		}
		var text = $(obj).find("option:selected").text().trim();
		$('#'+hiidenId).attr('value',text); 
		 
		var params = {
			"regionId" : regionId
		};

		$.getJSON(url, params, function callback(data) {
			 var regions = data.systemRegionss;
			 $('#'+subId).html('');
			 var str = '<option value="">请选择...	</option>';	
			 $(regions).each(function(index, region) {
				 str += '<option value="' + region.regionId + '">' + region.localName + '</option>';
			 });
			 $('#'+subId).html(str);

		});
	}
	
	
</script>
	</body>
</html>